|
|
|
|
|
|
|
Example program LineTo, shown in Figure 2.4, compares the MoveToEx and LineTo functions with the Visual Basic's Line method. It fills two picture boxes with small line segments, one using the Line method and one using the MoveToEx and LineTo functions. In one set of tests on a 133MHz Pentium, drawing the lines using the Line method took more than three times as long. |
|
|
|
|
|
|
|
|
The Polyline, Polygon, PolyPolyline, and PolyPolygon functions let you draw many line segments all at once. The following code shows the Visual Basic declarations for these functions. |
|
|
|
 |
|
|
|
|
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function Polyline Lib "gdi32" _
Alias "Polyline" (ByVal hdc As Long, _
lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Declare Function Polygon Lib "gdi32" _
Alias "Polygon" (ByVal hdc As Long, _
lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Declare Function PolyPolyline Lib "gdi32" _
Alias "PolyPolyline" (ByVal hdc As Long, _
lppt As POINTAPI, lpdwPolyPoints As Long, _
ByVal cCount As Long) As Long |
|
|
|
|
|
|
|
|
Figure 2.4
Example program LineTo compares the speeds of
Visual Basic's Line statement and the LineTo API function. |
|
|
|
|
|